home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / hotjava / classsrc / browser / ddtagr~1.jav < prev    next >
Encoding:
Text File  |  1995-08-11  |  1.7 KB  |  64 lines

  1. /*
  2.  * @(#)DDTagRef.java    1.9 95/03/14 Jonathan Payne
  3.  *
  4.  * Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19.  
  20. package browser;
  21.  
  22. import java.util.*;
  23. import java.io.*;
  24. import awt.*;
  25. import net.*;
  26. import net.www.http.*;
  27. import net.www.html.*;
  28.  
  29. /**
  30.  * An instance of class DDTagRef is created for <dd> tags that
  31.  * appear in html document.
  32.  * @version 1.9, 14 Mar 1995
  33.  * @author Jonathan Payne
  34.  */
  35.  
  36. public class DDTagRef extends WRTagRef {
  37.     static int MIN_SPACING = 10;
  38.     static int TERM_SPACE = 45;
  39.  
  40.     public DDTagRef(Tag t, int pos, boolean isEnd) {
  41.     super(t, pos, isEnd);
  42.     }
  43.  
  44.     public void apply(WRFormatter f) {
  45.     WRListRef   r = f.listContext();
  46.     boolean        compact = (r != null && r.getAttribute("compact") != null);
  47.     int        lm;
  48.  
  49.     if (r != null) {
  50.         lm = r.margin;
  51.     } else {
  52.         lm = 20;
  53.     }
  54.     int ddstart = lm + TERM_SPACE;
  55.  
  56.     if (!compact || f.getXCoordinate() + MIN_SPACING >= ddstart) {
  57.         f.breakLine(0);
  58.     } else {
  59.         f.setXCoordinate(ddstart);
  60.     }
  61.     f.setLeftMargin(ddstart);
  62.     }
  63. }
  64.